function [Stage] = ClassifyBasedOnSpindle(SleepSpindle, SpindleIntervalThreshold, Interval)

    countStage1 = 0;
    countStage2 = 0;
    StageDeterminingThresholdDifference = 0;
    for i = 0 : length(SleepSpindle)
        if SleepSpindle(i) == 1 
            for j = i + 1 : SpindleIntervalThreshold/Interval + i
                if SleepSpindle(i+1) == 1
                    countStage2 = countStage2 + 1;
                    break;
                elseif j == SpindleIntervalThreshold/Interval + i
                    countStage1 = countStage1 + 1;
                end
            end
            i = SpindleIntervalThreshold/Interval + i + 1;
        end
    end
    if (countStage1 > countStage2 + StageDeterminingThresholdDifference)
        Stage = 1;
    elseif (countStage2 > countStage1 + StageDeterminingThresholdDifference)
        Stage = 2;
    else
        Stage = -1;
    end
end
